package aml.runtime;

public class ValueNum extends Value {
	
	private double value;

	public ValueNum(final double value) {
		this.value = value;
		
		slots.put("+", new Method() {

			@Override
			public Value apply(Context ctx, Value[] args) {
				ValueNum other = args[0].toNum();
				return new ValueNum(value + other.value);
			}
			
		});
		
		slots.put("*", new Method() {

			@Override
			public Value apply(Context ctx, Value[] args) {
				ValueNum other = args[0].toNum();
				return new ValueNum(value * other.value);
			}
			
		});
	}
	
	public double getValue() {
		return value;
	}
	
	public String toString() {
		return Double.toString(value);
	}

	@Override
	public ValueNum toNum() {
		return this;
	}

}
